package com.topup.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.topup.pojo.Student;
import com.topup.pojo.User;
import com.topup.service.StudentService;
import com.topup.service.serviceimpl.UserServiceimpl;
import com.topup.until.Result;


@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
     private UserServiceimpl userServiceimpl;
    
    @Autowired
    private StudentService stuservice;
    
    @RequestMapping("ss")
    public void se() {
    	System.out.println("haah ");
    }
    
    
    @RequestMapping("add")
    @ResponseBody
    public Result adduser(HttpServletRequest request, HttpServletResponse response) throws  Exception {

        Result r = new Result();
        String name1 = request.getParameter("name");
        String pwd1 = request.getParameter("pwd");
        String classs = request.getParameter("classs");

        String phone = request.getParameter("phone");
         
        String email = request.getParameter("email");
       
        Student stu =new Student(name1, classs, pwd1, email, phone);
          int a =stuservice.addone(stu);
         System.out.println(a);
        if (a == 0) {
            r.setStatus("0");

            System.out.println("失败");
        } else {
            r.setStatus("1");
            r.setMsg("成功");
        }

        return r;
    }
}
